home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
526-550
/
disk_549
/
ffex
/
source
/
request.mod
< prev
Wrap
Text File
|
1992-05-06
|
9KB
|
305 lines
IMPLEMENTATION MODULE Request;
FROM Menu IMPORT InitText;
FROM Intuition IMPORT IntuiText, AutoRequest, Gadget, StringInfo, Border,
GadgetFlags, GadgetFlagSet, ActivationFlags,
ActivationFlagSet, boolGadget, strGadget,
WindowPtr, IntuiTextPtr, IDCMPFlags,IDCMPFlagSet,
OpenWindow,CloseWindow,NewWindow, WindowFlags,
WindowFlagSet, RefreshGadgets, ScreenPtr, customScreen,
IntuiMessagePtr, ActivateGadget;
FROM Exec IMPORT WaitPort,GetMsg,ReplyMsg,CopyMem;
FROM Graphics IMPORT jam1, SetAPen, SetRast, Move, Draw, RectFill, Text,
SetDrMd, RastPortPtr, TextLength;
FROM SYSTEM IMPORT INLINE,ADR,ADDRESS, LONGSET;
FROM Arts IMPORT Assert, TermProcedure;
FROM Str IMPORT FirstPos,Length,noOccur,Copy,Concat;
FROM Conversions IMPORT StrToVal,ValToStr;
FROM LongRealConversions IMPORT StrToReal,RealToStr;
VAR i,j : INTEGER;
(*** Requester *******************************************************)
CONST MAXBODYLINES=6;
OK=IDCMPFlagSet{};
VAR bodytxt : ARRAY[0..MAXBODYLINES-1] OF IntuiText;
bodylines : ARRAY[0..MAXBODYLINES-1],[0..79] OF CHAR;
postxt,negtxt : IntuiText;
index,p,len,
oldpos,maxlen,
maxi,w,h : INTEGER;
padr,nadr : ADDRESS;
PROCEDURE Request(win:WindowPtr; VAR body,pos,neg:ARRAY OF CHAR):BOOLEAN;
BEGIN
(*** body in Zeilen zerlegen (mit | unterteilt) ***)
index:=0; oldpos:=0;
REPEAT
p:=FirstPos(body,oldpos,'|');
IF p=noOccur THEN
CopyMem(ADR(body[oldpos]),ADR(bodylines[index]),
INTEGER(Length(body))-oldpos);
bodylines[index,INTEGER(Length(body))-oldpos]:=CHAR(0);
ELSE
CopyMem(ADR(body[oldpos]),ADR(bodylines[index]),p-oldpos);
bodylines[index,p-oldpos]:=CHAR(0);
END;
oldpos:=p+1;
INC(index);
UNTIL p=noOccur;
(*** größte Länge feststellen ***)
maxlen:=0; maxi:=0;
FOR i:=0 TO index-1 DO
len:=Length(bodylines[i]);
IF len>maxlen THEN maxlen:=len; maxi:=i END;
END;
FOR i:=0 TO index-1 DO
InitText(bodytxt[i],10,5+i*10,ADR(bodylines[i]));
END;
FOR i:=0 TO index-2 DO
bodytxt[i].nextText:=ADR(bodytxt[i+1])
END;
InitText(postxt,6,3,ADR(pos)); (* wegen ADR(pos), ADR(neg) sind *)
InitText(negtxt,6,3,ADR(neg)); (* pos und neg VAR Parameter!!! *)
padr:=ADR(postxt); nadr:=ADR(negtxt);
IF Length(pos)=0 THEN padr:=NIL END;
w:=TextLength(win^.rPort,ADR(bodylines[maxi]),maxlen)+38;
h:=42+index*10;
RETURN (AutoRequest(win, ADR(bodytxt[0]), padr, nadr, OK, OK, w, h));
END Request;
(*** Info-Requester *************************************************)
VAR infotext:ARRAY[0..255] OF CHAR;
ok,nok:ARRAY[0..9] OF CHAR;
PROCEDURE Info(win:WindowPtr);
BEGIN IF Request(win,infotext,ok,nok) THEN END; END Info;
(*** Limit-Requester *************************************************)
CONST
STR=ActivationFlagSet{gadgImmediate};
BOOL=ActivationFlagSet{gadgImmediate,relVerify};
EXPO=FALSE; (* Zahlen in Exponentenschreibweise *)
RMIN=-2.1;
RMAX=0.6;
IMIN=-1.0;
IMAX=1.0;
ITER=50;
VAR
wi : WindowPtr;
strinfo : ARRAY[0..4] OF StringInfo;
gad : ARRAY[0..8] OF Gadget;
buff : ARRAY[0..3],[0..20] OF CHAR;
iterbuff : ARRAY[0..5] OF CHAR;
undo : ARRAY[0..20] OF CHAR;
nw : NewWindow;
msg : IntuiMessagePtr;
id : INTEGER;
help : POINTER TO Gadget;
rp : RastPortPtr;
PROCEDURE InitGad(nr,x,y,w,h:INTEGER;
act:ActivationFlagSet;
typ:CARDINAL;info:ADDRESS);
BEGIN
WITH gad[nr] DO
nextGadget:=NIL; leftEdge:=x;topEdge:=y;width:=w;height:=h;
flags:=GadgetFlagSet{};activation:=act;
gadgetType:=typ;
gadgetRender:=NIL; selectRender:=NIL;
gadgetText:=NIL; mutualExclude:=LONGSET{};
specialInfo:=info; gadgetID:=nr;userData:=NIL;
END;
END InitGad;
PROCEDURE BufferToVal(VAR rmin,rmax,imin,imax:LONGREAL;
VAR maxiter:LONGINT):BOOLEAN;
(* Gadgets auslesen, bei falscher Eingabe Gad aktivieren *)
VAR
err,dummy,sign:BOOLEAN;
BEGIN
sign:=FALSE;
StrToReal(buff[0],rmin,err);
IF err THEN dummy:=ActivateGadget(ADR(gad[0]),wi,NIL);
RETURN FALSE; END;
StrToReal(buff[1],rmax,err);
IF err THEN dummy:=ActivateGadget(ADR(gad[1]),wi,NIL);
RETURN FALSE;END;
StrToReal(buff[2],imin,err);
IF err THEN dummy:=ActivateGadget(ADR(gad[2]),wi,NIL);
RETURN FALSE;END;
StrToReal(buff[3],imax,err);
IF err THEN dummy:=ActivateGadget(ADR(gad[3]),wi,NIL);
RETURN FALSE;END;
StrToVal(iterbuff,maxiter,sign,10,err);
IF err THEN dummy:=ActivateGadget(ADR(gad[4]),wi,NIL);
RETURN FALSE;END;
RETURN TRUE;
END BufferToVal;
PROCEDURE ValToBuffer(rmin,rmax,imin,imax:LONGREAL;iter:LONGINT);
VAR
err:BOOLEAN;
BEGIN
RealToStr(rmin,buff[0],12,10,EXPO,err);
RealToStr(rmax,buff[1],12,10,EXPO,err);
RealToStr(imin,buff[2],12,10,EXPO,err);
RealToStr(imax,buff[3],12,10,EXPO,err);
ValToStr(iter,FALSE,iterbuff,10,-5,CHAR(0),err);
RefreshGadgets(ADR(gad[0]),wi,NIL);
END ValToBuffer;
PROCEDURE GetLimits(s:ScreenPtr;
VAR rmin,rmax,imin,imax:LONGREAL;
VAR maxiter:LONGINT);
BEGIN
nw.screen:=s;
nw.leftEdge:=(s^.width-300)/2; (* Window zentrieren *)
nw.topEdge:=(s^.height-89)/2-10; (* 10 Pixel über der Mitte *)
wi:=OpenWindow(nw);
Assert(wi#NIL,ADR("Can't open Limits Window"));
rp:=wi^.rPort;
SetAPen(rp,1); RectFill(rp,0,10,299,88); (* Hintergrund *)
SetAPen(rp,2); RectFill(rp,2,10,297,87);
SetAPen(rp,1); RectFill(rp,4,12,295,63); RectFill(rp,4,66,295,85);
FOR i:=0 TO 3 DO (* Grafik für Bool Gadgets *)
SetAPen(rp,2);
RectFill(rp,14+i*70,68,71+i*70,82);
RectFill(rp,18+i*70,70,75+i*70,84);
SetAPen(rp,1);
RectFill(rp,15+i*70,69,70+i*70,81);
END;
FOR i:=0 TO 1 DO
FOR j:=0 TO 1 DO
SetAPen(rp,2); RectFill(rp,57+i*121,15+j*18,162+i*121,24+j*18);
SetAPen(rp,0); RectFill(rp,58+i*121,16+j*18,161+i*121,23+j*18);
END;
END;
SetAPen(rp,2); RectFill(rp,105,51,162,60);
SetAPen(rp,0); RectFill(rp,106,52,161,59);
(* Texte ausgeben *)
SetDrMd(rp,jam1); SetAPen(rp,2);
Move(rp,16,22); Text(rp,ADR("Real"),4);
Move(rp,158,22); Text(rp,ADR(" ; "),3);
Move(rp,16,40); Text(rp,ADR("Imag"),4);
Move(rp,158,40); Text(rp,ADR(" ; "),3);
Move(rp,16,58); Text(rp,ADR("Iterations"),10);
SetAPen(rp,0);
Move(rp,35,78); Text(rp,ADR("OK"),2);
Move(rp,93,78); Text(rp,ADR("Reset"),5);
Move(rp,168,78); Text(rp,ADR("Undo"),4);
Move(rp,230,78); Text(rp,ADR("CANCEL"),6);
ValToBuffer(rmin,rmax,imin,imax,maxiter);
RefreshGadgets(ADR(gad[0]),wi,NIL); (* Gadgets zeigen *)
(*** Eingaben: ***)
LOOP
WaitPort(wi^.userPort);
msg:=GetMsg(wi^.userPort);
WHILE msg#NIL DO
IF closeWindow IN msg^.class THEN
ReplyMsg(msg);
ValToBuffer(rmin,rmax,imin,imax,maxiter); EXIT;
ELSIF gadgetUp IN msg^.class THEN
id:=-1;
help:=msg^.iAddress;
id:=help^.gadgetID;
ReplyMsg(msg);
CASE id OF
5 : IF BufferToVal(rmin,rmax,imin,imax,maxiter) THEN EXIT END; |
6 : ValToBuffer(RMIN,RMAX,IMIN,IMAX,ITER); |
7 : ValToBuffer(rmin,rmax,imin,imax,maxiter); |
8 : ValToBuffer(rmin,rmax,imin,imax,maxiter); EXIT; |
ELSE;
END;
END;
msg:=GetMsg(wi^.userPort);
END; (* WHILE *)
END; (* LOOP *)
CloseWindow(wi);
END GetLimits;
BEGIN
(*** Info Text initialisieren ***)
Copy(infotext, " Fast Fractal Exploration Set 4.0 |");
Concat(infotext," This program is public domain! |");
Concat(infotext," Code & Design by Rob Brandner |");
Concat(infotext,"Algorithm : Int_16 Int_32 Real |");
Concat(infotext,"Precision : 10E-04 10E-09 10E-16|");
Concat(infotext,"Speed : fast medium slow ");
ok:=""; nok:="OK";
(*** Limit-Requester-Strukturen initialisieren *********************)
FOR i:=0 TO 3 DO
WITH strinfo[i] DO
buffer:=ADR(buff[i]);maxChars:=21; undoBuffer:=ADR(undo);
bufferPos:=0;dispPos:=0;
END;
END;
WITH strinfo[4] DO
buffer:=ADR(iterbuff);maxChars:=6; undoBuffer:=ADR(undo);
bufferPos:=0;dispPos:=0;
END;
InitGad(0, 58,16,104,8,STR,strGadget,ADR(strinfo[0]));
InitGad(1,179,16,104,8,STR,strGadget,ADR(strinfo[1]));
InitGad(2, 58,34,104,8,STR,strGadget,ADR(strinfo[2]));
InitGad(3,179,34,104,8,STR,strGadget,ADR(strinfo[3]));
InitGad(4,106,52, 56,8,STR,strGadget,ADR(strinfo[4]));
InitGad(5, 15,69,56,13,BOOL,boolGadget,NIL);
InitGad(6, 85,69,56,13,BOOL,boolGadget,NIL);
InitGad(7,155,69,56,13,BOOL,boolGadget,NIL);
InitGad(8,225,69,56,13,BOOL,boolGadget,NIL);
FOR i:=0 TO 7 DO gad[i].nextGadget:=ADR(gad[i+1]) END;
WITH nw DO
width:=300; height:=89; detailPen:=0; blockPen:=1;
idcmpFlags:=IDCMPFlagSet{gadgetUp,closeWindow};
flags:=WindowFlagSet{windowDrag,windowClose,activate,noCareRefresh};
firstGadget:=ADR(gad[0]); checkMark:=NIL;
title:=ADR("Setup Limits for Rendering");
screen:=NIL; bitMap:=NIL;
minWidth:=0; minHeight:=0; maxWidth:=-1; maxHeight:=-1;
type:=customScreen;
END;
END Request.mod